package csx.study.demo.enums;

import java.util.concurrent.TimeUnit;

public enum CacheTTL {
    NULL(2, TimeUnit.MINUTES),
    SHOP(30, TimeUnit.MINUTES);

    private final long value;
    private final TimeUnit unit;

    CacheTTL(long value, TimeUnit unit) {
        this.value = value;
        this.unit = unit;
    }

    public long getValue() {
        return value;
    }

    public TimeUnit getUnit() {
        return unit;
    }

    // 获取以秒为单位的TTL值，方便Redis操作
    public long toSeconds() {
        return unit.toSeconds(value);
    }
}